/**
 * Creat with IntelliJ IDEA
 * Description:
 * User:WZW
 * Date:2021-12-27
 * Time:3:16
 */
import java.io.*;
import java.net.*;
public class Server
{
    public static void main(String args[])
    {
        ServerSocket server = null;
        Socket socketAtServer = null;
        DataOutputStream out = null;
        DataInputStream in = null;

        try
        {
            server = new ServerSocket(4333);
        }
        catch(IOException e1)
        {
            System.out.println("ERRO:"+e1);
        }
        try
        {
            socketAtServer = server.accept();
            in = new DataInputStream(socketAtServer.getInputStream());
            out = new DataOutputStream(socketAtServer.getOutputStream());
            while(true)
            {
                int m = 0;
                m = in.readInt();
                out.writeInt(m*2);
                System.out.println("Server received: " + m);
                Thread.sleep(500);
            }
        }
        catch(IOException e)
        {
            System.out.println(""+e);
        }
        catch(InterruptedException e){}
    }
}

